import redis
from djangoProject.settings import REDIS_HOST, REDIS_POST

r = redis.Redis(host=REDIS_HOST, port=REDIS_POST, db=0, charset="utf8", decode_responses=True)


def setRedisCode(key, value, time):
    # r = redis.Redis(host='localhost', port=6379, db=0)
    r.set(key, value)
    r.expire(key,time)


def getRedisCode(key):
    return r.get(key)
